﻿@model makitRS.Core.Models.Reports.ReportsCategory

@using makitRS.Core.Models.Reports;

@{
    ViewBag.Title = Model.CategoryName + " Reports";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Model.CategoryName Reports</h2>

@if (Model.Reports != null && Model.Reports.Count > 0)
{   
    <table class="prettyTable">
        <tr>
            <th>
                Report Name
            </th>
            <th>
                Report Date/Time
            </th>
            <th>&nbsp;</th>
        </tr>
    @foreach (var item in Model.Reports)
    {
        <tr id="row-@item.ReportID">
            <td>
                @item.ReportName
            </td>
            <td>
                @String.Format("{0:g}", item.ReportDateTime)
            </td>
            <td>
                <noscript>
                    @Html.ActionLink("Download", "Download", "Report", new { id = item.ReportID }, null)
                </noscript>
            </td>
        </tr>
    }
    </table>
    
    <script language="javascript" type="text/javascript">
    @foreach (var item in Model.Reports)
    {
        @:$('#row-@item.ReportID').click(function(e) {
        @:  e.preventDefault();  //stop the browser from following
        @:  window.location.href = '@Url.Action("Download", "Report", new { id = item.ReportID })';
        @:});
    }
    </script>
}
else
{
    <p>No reports in this category</p>
}
